package com.ihr360.event.annonation;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

public interface RestEventListener<T, ID extends Serializable> {
    default void beforeGetOne(ID id) {
    }

    default T afterGetOne(T t) {
        return t;
    }

    default void beforeGetAll() {
    }

    default Iterable<T> afterGetAll(Iterable<T> iterable) {
        return iterable;
    }

    default void beforeCreate(T t) {
    }

    default void afterCreate(T t) {
    }

    default void beforeUpdate(ID id, Map<String, Object> source,T t) {
    }

    default T afterUpdate(T t) {
        return t;
    }

    default void beforeCreateOrUpdate(ID id, T t) {
    }

    default T afterCreateOrUpdate(T t) {
        return t;
    }

    default void beforeDeleteOne(ID id) {
    }

    default void afterDeleteOne(ID id) {
    }

    default void beforeBatchDelete(List<ID> ids) {
    }

    default void afterBatchDelete(List<ID> ids) {
    }

    default Specification<T>  beforeSearch(Specification<T> specification, Pageable pageable) {
        return specification;
    }

    default Page<T> afterSearch(Page<T> pageData) {
        return pageData;
    }


}